// 弹出修改积分和修改余额
<template>
  <el-dialog
    title=""
    :visible.sync="centerDialogVisible"
    width="20%"
    center
  >
    <div class="header">
      <div class="top">
        <span v-if="stys==0">修改积分</span>
        <span v-else>修改余额</span>
      </div>
      <div class="center">
        <input type="text" placeholder="请输入修改积分" v-if="stys==0" v-model="num">
        <input type="text" placeholder="请输入修改余额" v-else v-model="nums">
      </div>
      <div class="bottom">
        <div class="btn">
          <button class="btn_determine" @click="determine">确认</button>
          <button class="btn_cancel" @click="cancel">取消</button>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "Modify",
  props:[
    'stys',
    'user_id'
  ],
  data() {
    return {
      centerDialogVisible: false,
      num:'',
      nums:'',
      text:''
    };
  },
  methods: {
    // 确定修改
    determine() {
      if(this.stys==0){
        if(this.num==''){
          this.$message({
            type: "error",
            message: "请输入需要修改的积分",
          });
        }else{
          this.$axios({
            method: 'post',
            url:'/user/user_integral_up',
            params:{
              id:this.user_id,
              integral:this.num
            }
          })
          .then((res) => {
            if(res.data.status==0){
              this.$message({
                type: "success",
                message: "修改积分成功",
              });
            }else{
              this.$message({
                type: "success",
                message: "修改积分失败",
              });
            }
          })
          
          this.centerDialogVisible = false;
        }
      }else if(this.stys==1){
        if(this.nums==''){
          this.$message({
            type: "error",
            message: "请输入需要修改的余额",
          });
        }else{
          this.$axios({
            method: 'post',
            url:'/user/user_balance_modification',
            params:{
              id:this.user_id,
              balance:this.nums
            }
          })
          .then((res) => {
            if(res.data.status==0){
              this.$message({
                type: "success",
                message: "修改余额成功",
              });
            }else{
              this.$message({
                type: "success",
                message: "修改余额失败",
              });
            }
          })
          
          this.centerDialogVisible = false;
        }
      }
    },
    // 取消冻结
    cancel() {
      this.centerDialogVisible = false;
    },
  },
  created(){
  }
};
</script>
<style scoped>
.header {
  margin: 0 auto;
  padding: 0;
  border-radius: 10px;
}
.top {
  margin: 21px auto;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: #484848;
}
input{
  outline: none;
  height:30px;
  line-height:30px;
  text-indent: 0.5em;
  border:1px solid #757575;
  border-radius: 5px;
  font-size:14px;
}
.center {
  margin: 0 auto;
  margin-bottom: 40px;
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  color: #484848;
}
.bottom {
  margin: 0 auto;
  text-align: center;
}
.btn {
  display: inherit;
  margin: 0 auto;
}
.btn button {
  cursor: pointer;
}
span {
  text-align: center;
}
</style>